<%@ page language="java" import="java.util.*" import="java.sql.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="blog.anchen8.net" />
<title>毕业生，你的选择</title>
<link rel="stylesheet" type="text/css" href="../css/blog.css" />
<script type="text/javascript">
	function createMain() {
		var _scrollWidth = Math.max(document.body.scrollWidth,
				document.documentElement.scrollWidth);
		var _scrollHeight = Math.max(document.body.scrollHeight,
				document.documentElement.scrollHeight);
		document.getElementById("main").style.left = (_scrollWidth - 950) / 2
				+ "px";
		// document.getElementById("m").style.height=_scrollHeight+"px";
	}
	function logohover() {
		document.getElementById("logoblog").style.opacity = 0.6;
	}
	function logoout() {
		document.getElementById("logoblog").style.opacity = 1.0;
	}
</script>
</head>
<jsp:useBean id="sql" scope="page" class="com.tzq.JAVABEAN.ConnectDB"></jsp:useBean>
<body class="body">
	<div class="main" id="main">
		<div class="search">
			<div class="logoblog" id="logoblog" onmouseover="logohover()"
				onmouseout="logoout()">
				<img src="/Bys-Website/SourceImageFile/bloglogo.jpg" />
			</div>
			<div class="searchbar">
				<input class="searchtext" type="text" dir="毕业博客"
					style="color: #777;"
					onfocus="if(this.value==this.getAttribute('dir')){this.value=''} this.style.color='#000'"
					onblur="if(this.value==''){this.value=this.getAttribute('dir')}this.style.color='#777'"
					value="毕业博客" /> <input type="button" value="搜索" class="searchbtn" />
			</div>
			<div class="blogswitch">
				<ul class="blogswul">
					<li class="swclickli" id="swclickli"><a href="#"
						onclick="blogswitch('total')">点击榜</a></li>
					<li class="swnewli" id="swnewli"><a href="#"
						onclick="blogswitch('new')">新文榜</a></li>
				</ul>
			</div>
		</div>
		<div class="left">
			<div class="special">
				<a href="#">&nbsp;刘江永：中日间存在军事较量可能性</a>
				<div class="speimg">
					<img src="/Bys-Website/SourceImageFile/blog/1.jpg" />
				</div>
				<div class="spedes">&nbsp;&nbsp;&nbsp;&nbsp;清华大学当代国际关系
					研究院副院长刘江永教授表 示：中日两国军事较量的危 险性是存在的。</div>
			</div>
			<div class="special">
				<a href="#">&nbsp;萧功秦：高调民族主义非中国之福</a>
				<div class="speimg">
					<img src="/Bys-Website/SourceImageFile/blog/2.jpg" />
				</div>
				<div class="spedes">&nbsp;&nbsp;&nbsp;&nbsp;邓小平曾说过：“我们
					的子孙比我们更聪明，他们 会有更好的解决办法。”</div>
			</div>
			<div class="special">
				<a href="#">&nbsp;“泰州蟹谢你”感恩故事有奖征集性</a>
				<div class="speimg">
					<img src="/Bys-Website/SourceImageFile/blog/3.jpg" />
				</div>
				<div class="spedes">&nbsp;&nbsp;&nbsp;&nbsp;金秋感恩季，说出你的
					感恩故事，有机会为自己和 感恩对象，各赢得泰州美蟹 一份，以蟹传情！</div>
			</div>
			<div class="special">
				<a href="#">&nbsp;刘江永：中日间存在军事较量可能性</a>
				<div class="speimg">
					<img src="/Bys-Website/SourceImageFile/blog/1.jpg" />
				</div>
				<div class="spedes">&nbsp;&nbsp;&nbsp;&nbsp;清华大学当代国际关系
					研究院副院长刘江永教授表 示：中日两国军事较量的危 险性是存在的。</div>
			</div>
			<div class="special">
				<a href="#">&nbsp;萧功秦：高调民族主义非中国之福</a>
				<div class="speimg">
					<img src="/Bys-Website/SourceImageFile/blog/2.jpg" />
				</div>
				<div class="spedes">&nbsp;&nbsp;&nbsp;&nbsp;邓小平曾说过：“我们
					的子孙比我们更聪明，他们 会有更好的解决办法。”</div>
			</div>
			<div class="special">
				<a href="#">&nbsp;“泰州蟹谢你”感恩故事有奖征集性</a>
				<div class="speimg">
					<img src="/Bys-Website/SourceImageFile/blog/3.jpg" />
				</div>
				<div class="spedes">&nbsp;&nbsp;&nbsp;&nbsp;金秋感恩季，说出你的
					感恩故事，有机会为自己和 感恩对象，各赢得泰州美蟹 一份，以蟹传情！</div>
			</div>
			<div class="special">
				<a href="#">&nbsp;“泰州蟹谢你”感恩故事有奖征集性</a>
				<div class="speimg">
					<img src="/Bys-Website/SourceImageFile/blog/3.jpg" />
				</div>
				<div class="spedes">&nbsp;&nbsp;&nbsp;&nbsp;金秋感恩季，说出你的
					感恩故事，有机会为自己和 感恩对象，各赢得泰州美蟹 一份，以蟹传情！</div>
			</div>
		</div>
		<div class="mid">
			<div class="top3">
				<ul>
					<%
						//博文总排名前三
					String selectBlogTop3 = "select * from Blog,Userinfo where AuthorID=UserID order by ClickTimes DESC";
					ResultSet rsBlogTop3 = sql.executeQuery(selectBlogTop3);
					int i=1;
					while(rsBlogTop3.next()){
					String Blogname = rsBlogTop3.getString("BlogName");
					String Authorid = rsBlogTop3.getString("AuthorID");
					String content = rsBlogTop3.getString("BlogContext");
					content = content.substring(0,54)+"...";
					%>
					<li>
						<div class="top3title">
							<a
								href="/Bys-Website/PersonBlog/ShowBlogContext.jsp?blogname=<%=Blogname%>&authorid=<%=Authorid%>"><%=Blogname%></a>
						</div>
						<p><%=content%></p>
					</li>
					<%
						if(i<3){
					%>
					<div class="ashr"></div>
					<%
						}
					i++;
					if(i>3){
						break;
					}
					}
					%>

				</ul>
			</div>
			<%//随机三所学校的前十博文 
			String selectSchoolrand = "SELECT  CollegeName FROM Schools GROUP BY CollegeName";
			ResultSet rsschoolrand = sql.executeQuery(selectSchoolrand);
			Random random = new Random();
			int[] row= new int[3];
			while(true){
				row[0] = random.nextInt(4)+1;
				row[1] = random.nextInt(4)+1;
				row[2] = random.nextInt(4)+1;
				if(row[0]!=row[1]&&row[0]!=row[2]&&row[1]!=row[2]){
					break;
				}
			}
			for(int y=0;y<3;y++){
				if(rsschoolrand.absolute(row[y])){ 
					String selectSchoolBlog = "select TOP 8 * from Schools,Userinfo,Blog where Schools.CollegeName='"+rsschoolrand.getString("CollegeName")+"' and Userinfo.SchoolID=Schools.SchoolID and Userinfo.UserID=Blog.AuthorID order by ClickTimes DESC ";
					String schoolname= rsschoolrand.getString("CollegeName"); %>
			<div class="schblog">
				<div class="schname"><%=schoolname %></div>
				<ul>
					<%ResultSet rsSchoolBlog =sql.executeQuery(selectSchoolBlog); 
					
					while(rsSchoolBlog.next()){ 
						String Blogname = rsSchoolBlog.getString("BlogName"); 
						String Authorid =rsSchoolBlog.getString("AuthorID");%>
					<li><a href="/Bys-Website/PersonBlog/ShowBlogContext.jsp?blogname=<%=Blogname %>&authorid=<%=Authorid%>"><%=Blogname%></a></li>
					<%}%>
				</ul>
			</div>
			<%}
			}%>
		</div>
		<div class="right">
			<div class="rank">
				<div class="ranktitle">
					<br /> 博文学校榜
				</div>
				<div class="thr"></div>
				<ul>
					<%
						String selectschoolrank = "select top 10 SUM(ClickTimes) AS A,CollegeName from Userinfo,Blog,Schools where Userinfo.SchoolID= Schools.SchoolID and Userinfo.UserID=Blog.AuthorID GROUP BY CollegeName order by A DESC" ;
					ResultSet rsschoolrank = sql.executeQuery(selectschoolrank);
					int schIndex=1;
					while(rsschoolrank.next()){%>
					<% if(schIndex<4){%>
					<li>
						<div class="rcolor1"><%=schIndex %></div> <span><%=rsschoolrank.getString("CollegeName") %></span>
					</li>
					<%}
						else{%>
					<li>
						<div class="rcolor2"><%=schIndex %></div> <span><%=rsschoolrank.getString("CollegeName") %></span>
					</li>
					<%}
						
					schIndex++;}%>
				</ul>
			</div>
			<div class="rank">
				<div class="ranktitle">
					<br /> 博文个人榜
				</div>
				<div class="thr"></div>
				<ul>
					<% String selectpersonrank = "select top 10 sum(ClickTimes) AS B,UserName,UserID from Blog,Userinfo where Userinfo.UserID= Blog.AuthorID group by UserName ORDER BY B DESC";
				ResultSet rspersonrank = sql.executeQuery(selectpersonrank);
				int userIndex=1;
				while(rspersonrank.next()){%>
					<%if(userIndex<4){%>
					<li>
						<div class="rcolor1"><%=userIndex %></div> <a href="/Bys-Website/PersonMainPage.jsp?userID=<%=rspersonrank.getString("UserID") %>"><span><%=rspersonrank.getString("UserName") %></span></a>
					</li>
					<%}else{%>
					<li>
						<div class="rcolor2"><%=userIndex %></div> <a href="/Bys-Website/PersonMainPage.jsp?userID=<%=rspersonrank.getString("UserID") %>"><span><%=rspersonrank.getString("UserName") %></span></a>
					</li>
					<%}
					userIndex++;}%>
				</ul>
			</div>
		</div>
	</div>
	<script>
		createMain();
	</script>
	<div class="topbar">
		<div class="logo">
			<a href="/Bys-Website/Public/home.jsp">
            	<img src="/Bys-Website/SourceImageFile/toplogo.jpg"/>
            </a>
		</div>
		<div class="navi">
			<ul class="naviul">
				<li><a href="/Bys-Website/Public/Video.jsp" class="outli">视频</a></li>
				<li><a href="/Bys-Website/Public/Photo.jsp" class="outli">相册</a></li>
				<li><a href="/Bys-Website/Public/Blog.jsp" class="inli">博客</a></li>
			</ul>
		</div>
		<div class="loginfo">
			<ul class="loginfoul">
				<%if(session.getAttribute("pid")==null){%>
				<li><a href="/Bys-Website/Log_in.jsp">登录</a></li>
				<li><a href="/Bys-Website/Regist.jsp">注册</a></li>
			<%}else{
			     String Sessionid =session.getAttribute("pid").toString(); %>
				<li><a href="../PersonMainPage.jsp?userID=<%=Sessionid  %>"><%=session.getAttribute("username").toString()%></a></li>
				<li><a href="../LoginServlet?method=1">退出</a></li>
			<%}%>
			</ul>
		</div>
	</div>
</body>
</html>

